<template>
	<view class="listinfo" style="padding: 20rpx;">
		<u-sticky>
			<!-- 选择框 -->
			<u-search :show-action="true" placeholder="搜索旅游信息" v-model="value" margin="0" @search="search(value)" @custom="search(value)"></u-search>
			
		</u-sticky>
		
		<view class="" v-for="(item,index) in list" :key="index" style="width: 100%;"> 
			<view class="" style="display: flex;padding: 20rpx;" @click="details(item)">
				<view class="" style="flex: 1;width: 300rpx;">
					<image :lazy-load="true" :src="item.img" mode="" style="width: 300rpx;height: 200rpx;border-radius: 20rpx;"></image>
				</view>
				<view class="" style="flex: 2;padding: 20rpx;font-size: 30rpx;">
					<view style="color: #0285ff;font-weight: bold;">{{item.title}}</view> 
					<view style="color: #8F8F94;margin-top: 50rpx;"><u-icon name="chat"></u-icon>评论：{{item.comment}}条</view> 
					<view class="u-flex">
						<text style="color: #FA3534;font-weight: bold;flex: 1;">￥{{item.price}}元起</text>
						<view class="u-text-right u-flex-1 u-font-28" style="color: #88c6ff;">
							查看详情<u-icon name="arrow-right"></u-icon>
						</view>
					</view> 
				</view>
				
			</view>
			
		</view>
		
		<u-divider>没有啦</u-divider>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				x:"",
				lists:[],
				value:'',
				list:[]
				// seachlist:[]
			}
		},
		mounted() {
			uni.request({
			  url: "http://127.0.0.1:4523/m1/1653531-0-default/info",
			  success: (res) => {
				if(this.x=="hotlist"){
					this.lists=res.data.data[0].hotlist
					
				}else if(this.x=="recommendlist"){
					this.lists=res.data.data[0].recommendlist
				}else if(this.x=="scenicspot"){
					this.lists=res.data.data[0].scenicspot
				}else{
					// console.log("不对")
					this.lists=res.data.data[0].scenicspot.filter(y=>
						// console.log(this.seachlist)
						y.title.includes(this.x)
					)
				}
				this.list=this.lists
				// console.log(this.list)
			  },
			  fail: (err) => {
			    // console.error(err,11111111111);
			  },
			});
			
		},
		methods: {
			search(value){
				this.list=this.lists.filter(x=>
					// console.log(this.seachlist)
					x.title.includes(value)
					
				)
				// console.log(seachlist)
				// console.log(this.seachlist)
			},
			details(item){
				uni.navigateTo({
				    url: '/pages/home/details/details?item='+encodeURIComponent(JSON.stringify(item))
				})
			}
		},
		onLoad(option) {
			this.x=JSON.parse(option.x)
			// this.lists=JSON.parse(decodeURIComponent(option.seach))
			// console.log(this.x)
		}
	}
	
</script>

<style>
	
</style>

